<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>人事安排</title>
    <link href="../../static/css/bootstrap.min.css" rel="stylesheet" th:href="@{/static/css/bootstrap.min.css}">
    <link href="../../static/css/dashboard.css" rel="stylesheet" th:href="@{/static/css/dashboard.css}">
</head>
<body>
<div th:insert="admin/common::topbar"></div>
<div class="container-fluid">
    <div class="row">
        <!--侧边栏-->
        <div th:insert="~{admin/common::sidebar(active='classInfo.html')}"></div>
        <main class="col-md-9 ml-sm-auto col-lg-10 pt-3 px-4" role="main">
            <div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pb-2 mb-3 border-bottom">
                <h1 class="h3">人事安排</h1>
                <div class="btn-toolbar mb-2 mb-md-0">
                    <div class="btn-group mr-2">
                        <button class="btn btn-primary btn-sm btn-outline-secondary" id="btn-admin">管理员</button>
                        <button class="btn btn-sm btn-outline-secondary" id="btn-student">学生端</button>
                    </div>
                </div>
            </div>
            <div class="table-responsive">
                <table class="table table-striped table-sm">
                    <thead>
                    <tr style="background-color: #0da8ee">
                        <th>教师编号</th>
                        <th>姓名</th>
                        <th>性别</th>
                        <th>任职科目</th>
                        <th>任职班级</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr class="teacherList" th:each="teacher:${teacherList}">
                        <td th:text="${teacher.getTid()}"></td>
                        <td th:text="${teacher.getTname()}"></td>
                        <td th:text="${teacher.getGender()}"></td>
                        <td th:text="${teacher.getSubject()}"></td>
                        <td th:text="${teacher.getTeacher_class()}"></td>
                        <td>
                            <button class="btn btn-primary btn-sm btn-outline-secondary" th:value="${teacher.getTid()}">
                                任免职位
                            </button>
                            <!-- <button th:value="${teacher.getTid()}" class="btn btn-primary btn-sm btn-outline-secondary">解除职位</button>-->
                        </td>
                    </tr>
                    </tbody>
                </table>
            </div>
        </main>
    </div>
</div>
<script src="../../static/js/jquery-3.6.0.min.js" th:src="@{/static/js/jquery-3.6.0.min.js}"
        type="text/javascript"></script>
<script src="../../static/js/bootstrap.min.js" th:src="@{/static/js/bootstrap.min.js}" type="text/javascript"></script>
<script>
    $(function () {
        $('.teacherList').each(function () {
            let arrange = $(this).children().eq(5).children();
            /* let dim=$(this).children().eq(5).children().eq(1);*/
            let tid = arrange.val();
            let class_name = $(this).children().eq(4).text();
            arrange.click(function () {
                $.get({
                    url: "/admin/ajax/arrangeClassGuardian",
                    data: {"class_name": class_name, "tid": tid},
                    success: function (result) {
                        if (result === true) {
                            $(location).attr('href', '/admin/GetClass');
                        }
                    }
                })
            })

        })
        $('#btn-admin').click(function () {
            let result = confirm("是否进入管理员登录?");
            if (result === true) {
                $(location).attr('href', '/adminLogin.html');
            } else {

            }
        })
        $('#btn-student').click(function () {
            let result = confirm("是否重新登录?");
            if (result === true) {
                $(location).attr('href', '/studentLogin.html');
            } else {

            }
        })
    })
</script>
</body>
</html>